
#include<bits/stdc++.h>
using namespace std;
#define ll long long

set<ll>s;

bool is_prime(ll n)
{
    if (n < 2 )return false;
    if (n == 2)return true;
    if (n % 2 == 0)return true;
    for (int i = 3; i * i <= n; i += 2)
        if (n % i == 0)return false;
    return true;
}


bool check(ll x)//检查是否是完美银块
{
    ll tmp = (ll)sqrt(x);
    if (tmp * tmp != x)return  false;
    else  return is_prime(tmp);
}

int main()
{
    int n; cin >> n;
    vector<vector<ll>>a(n, vector<ll>(n));
    ll ret = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> a[i][j];
            if(s.count(a[i][j]))ret+=a[i][j];
            else
            if (check(a[i][j]))
            {
                ret += a[i][j];
                s.insert(a[i][j]);
            }
        }

    }
    cout << ret;
    return 0;
}
